/*
*    Qizx/open 3.0 beta
*
* This code is the open-source version of Qizx.
* Copyright (C) 2004-2009 Axyana Software -- All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License 
*  Version 1.1 (the "License"); you may not use this file except in 
*  compliance with the License. You may obtain a copy of the License at
*  http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
*  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
*  for the specific language governing rights and limitations under the
*  License.
*
* The Initial Developer of the Original Code is Xavier Franc - Axyana Software.
*
*/
using System;
using System.Qizx.Xml;
using System.Text;
using Node = System.Qizx.Api.Node;
namespace System.Qizx.Api.Util
{

    /// <summary> An extension of SAXSource that allows using a Qizx Document or Node as a
    /// source for an XSLT transformation.
    /// </summary>
    public class NodeSource : SaxSource
    {
        /// <summary> Returns the Node used as input by the XSLT transformation.</summary>
        /// <returns> the root node set in the constructor
        /// </returns>
        virtual public Node RootNode
        {
            get
            {
                return rootNode;
            }

        }
        private Node rootNode;

        /// <summary> Creates a NodeSource from a Node.</summary>
        /// <param name="node">the XML tree to transform by a XSLT processor.
        /// </param>
        public NodeSource(Node node)
            : base(new NodeXMLReader(node), new XmlSource(Encoding.UTF8.GetBytes("<dummy/>")))
        {
            rootNode = node;
        }
    }
}